package com.haidechizi.backup.tree;

/**
 * @author: wangdejun
 * @create: 2020-03-14 11:41
 **/
public class BinaryTree {

    public BinaryTree(Node root) {
        this.root = root;
    }

    private Node root;

    public Node getRoot() {
        return root;
    }

    public void setRoot(Node root) {
        this.root = root;
    }

    public Node searchNode(int i) {
        if (root == null) {
            return null;
        }
        return root.searchNode(i);
    }

    public void frontPrint() {
        if(root == null) {
            return;
        }
        this.root.frontPrint();
    }

    public void midPrint() {
        if(this.root == null) {
            return;
        }
        this.root.midPrint();
    }

    public void afterPrint() {
        if(this.root == null) {
            return;
        }
        this.root.afterPrint();
    }

    public void delete(int i) {
        if(root.getValue() == i){
            root = null;
            return;
        }
        root.delete(i);

    }

    public void deepShow() {
        if(root == null) {
            return;
        }
        root.deepShow();
    }
}
